#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e6+9;
const int INF=1e18;
int mod;
int T;
int n;
int dp[maxn];
void solve()
{
	cin>>n;
	cout<<dp[n]<<'\n';
}
signed main()
{
	freopen("moon.in","r",stdin);
	freopen("moon.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>T>>mod;
	int lim=3e3;
	dp[0]=1;
	for(int i=1;i<=lim;i+=2)
	{
		for(int j=lim;j>=i;j--) 
		{
			dp[j]=(dp[j]+dp[j-i])%mod;
		}
	}
	while(T--) solve();
	return 0;
}
